<?php 
require "DataLoad.php"; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="魔兽世界DKP系统 DKP程序 公会DKP">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="style/styleplus.js"></script>
<script language="JavaScript" src="inc/UBB_UI.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="header">
<?php require "menu.php"; ?>
</div>
<div class="main">

<div class="SearchFrame outframe">
	<h3>DKP查询</h3>
<form method=post action="default.php?action=Search">
	<input type="text" name="keyword"><input type="submit" value="查询">
	<br>输入角色名字
	<?php if ($SearchError!="") {
	print "<br><b>".$SearchError."</b>";
} ?>
</form>
</div>


<div class="sideframe outframe">
	<div class="raidlist">
	<h3>近期活动</h3>

		<?php 
$sql="select * from raid where raid_player is not NULL Order by raid_actiontime desc LIMIT 0,5";
$result_news=mysql_query($sql);
if (mysql_num_rows($result_news)===0) {
	print "<dd>没有活动</dd>";
} else {
	while($row = mysql_fetch_array($result_news)) {
?>
		<dl>
			<dt><a href="raid_report.php?id=<?php     echo $row['id'];?>"><?php     echo $row['raid_name'];?></a></dt>
			<dd class="date"><?php echo time_type($row['raid_concentratetime'],"11");?></dd>
			<dd class="raidclass"><?php echo getRaidClassText($row['raid_class']);?></dd>
			<dd class="commander"><?php echo $row['raid_commander'];?></dd>
			<dd class="plan"><?php echo substr($row['raid_plan'],0,80);?></dd>
		</dl>
<?php
	}
}

?>

	</div>
</div>

<div class="rightframe">
	<table class="outframe interlace">
	<?php 
print "<tr><th>DKP分类</th><th>查看</th><th>更新日期</th><th>管理</th></tr>";
$sql="select * from raid_class order by id";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
	print "<tr>";
	print "<td><b>".$row["class_name"]."</b> - ".$row["class_note"]."</td>";
	print "<td><a class='abtn' href='dkplist_".$row["id"].".html'>详细报表</a> <a class='abtn' href='dkpsimplelist_".$row["id"].".html'>简单列表</a> <a class='abtn' href='dkpText_".$row["id"].".html'>文本格式</a></td>";
	print "<td>".$row["closing_date"]."</td>";
	if (CheckAdmin()) {
		print "<td><a class='abtn' href='admin_dkplist.php?class=".$row["id"]."'>现在更新</a></td>";
	}else{
		print "<td>-</td>";
	} 
	print "";
}
	print "</tr></table>";




?>


	<div class="info outframe">
	<h3>公会动态 <?php if (CheckAdmin()) {
	print "<a href='?action=add'>添加</a>";
} ?></h3>
<?php 
 if (isset($_GET['action'])) {
	if (CheckAdmin() && ($_GET['action']=="add" || $_GET['action']=="edit")) {
NewsAddForm();
} 
	if (CheckAdmin() && $_GET['action']=="add2") {
NewsAddSql();
} 
	 if (CheckAdmin() && $_GET['action']=="del") {
NewsdelSql();
} 
 }
?>
	<?php 

$sql="select * from article where article_class='news' order by id desc";
$result = mysql_query($sql);
$ig = 0;
while ($row = mysql_fetch_array($result)) {
	$ig += 1;
	print "<div class='".linec($ig)."'>";
	print "<h4>".htmlspecialchars($row['article_title']).CAbutton($row['id'])."</h4>";
	print "<p>".nl2br(htmlspecialchars($row['article_text']))."</p>";
	print "</div>";
}
?>
	</div>
</div>
</div>

<?php require "footer.php"; ?>

</body>
</html>

<?php 

function WorldEventImg($thisday) {
	extract($GLOBALS);

	$Basedate="2005-1-17";
	$today=time();
	if (strftime("%w",$thisday)+1==3) {

		$renew=$renew."<img src='images/raid/mc.gif' /><img src='images/raid/bwl.gif' /><img src='images/raid/aq40.gif' />";
	}
		else
	{

		$renew=$renew."<img src='images/raid/none.gif' /><img src='images/raid/none.gif' /><img src='images/raid/none.gif' />";
	} 

	if ($datediff["d"][$Basedate][$thisday]/5==intval($datediff["d"][$Basedate][$thisday]/5)) {

		$renew=$renew."<img src='images/raid/onx.gif' />";
	}
		else
	{

		$renew=$renew."<img src='images/raid/none.gif' />";
	} 

	if ($datediff["d"][$Basedate][$thisday]/3==intval($datediff["d"][$Basedate][$thisday]/3)) {

		$renew=$renew."<img src='images/raid/zg.gif' /><img src='images/raid/aq20.gif' />";
	}
		else
	{

		$renew=$renew."<img src='images/raid/none.gif' /><img src='images/raid/none.gif' />";
	} 

	$function_ret=$renew;
	return $function_ret;
} 



function Calendar() {
	extract($GLOBALS);

	$Basedate="2005-1-17";
	$today=time();
	for ($i=0; $i<=6; $i=$i+1) {
		$thisday=$dateadd["d"][$i][$today];
		if (strftime("%w",$thisday)+1==3) {

			$renew=$renew."<img src='images/raid/mc.gif' /><img src='images/raid/bwl.gif' /><img src='images/raid/aq40.gif' />";
		}
			else
		{

			$renew=$renew."<img src='images/raid/none.gif' /><img src='images/raid/none.gif' /><img src='images/raid/none.gif' />";
		} 

		if ($datediff["d"][$Basedate][$thisday]/5==intval($datediff["d"][$Basedate][$thisday]/5)) {

			$renew=$renew."<img src='images/raid/onx.gif' />";
		}
			else
		{

			$renew=$renew."<img src='images/raid/none.gif' />";
		} 

		if ($datediff["d"][$Basedate][$thisday]/3==intval($datediff["d"][$Basedate][$thisday]/3)) {

			$renew=$renew."<img src='images/raid/zg.gif' /><img src='images/raid/aq20.gif' />";
		}
			else
		{

			$renew=$renew."<img src='images/raid/none.gif' /><img src='images/raid/none.gif' />";
		} 


		$tx=$tx."<li>".$day[$thisday].$renew."</li>";
		$renew="";

	}

	print "<div class='calendar'><ul><h3>".time_type(strftime("%m/%d/%Y %H:%M:%S %p"),"11")." <a target='_blank' href='http://www.google.com/calendar/render?cid=o2u1do6qk1r8ke4hp9a8gins30%40group.calendar.google.com'>添加到您的Google日历</a></h3>".$tx."</ul></div>";
	return $function_ret;
} 


function NewsAddForm() {


	if ($_GET['action']=="edit" && CheckAdmin()) {
		$editnewsid=checknum($_GET['var']);
		$sql="select * from article where article_class='News' and id=".$editnewsid." LIMIT 0,1";
		$result = mysql_query($sql);
		$row=mysql_fetch_assoc($result);
		print "<form name='put_log' method='post' action='?action=add2'><ul><li><input type='text' name='article_title' size='60' value='".$row['article_title']."' /> <a href='javascript:hyperlink()'>链接</a> <a href='javascript:image()'>图片</a> <a href='javascript:bold()'>加粗</a></li>";
		print "<li><textarea name='article_text' rows='8' cols='80' name='l_content' id='l_content'>".htmlspecialchars($row["article_text"])."</textarea></li>";
		print "<li><input type='hidden' name='article_date' value='".$row['article_date']."' /><input type='hidden' name='article_id' value='".$editnewsid."' /><input type='submit' value='编辑' /></li></ul></form>";
		mysql_free_result($result);
		unset($row);
	}
		else
	if ($_GET['action']=="add" && CheckAdmin()) {

		print "<form name='put_log' method='post' action='?action=add2'><ul><li><input type='text' name='article_title' size='60' value='' /> <a href='javascript:hyperlink()'>链接</a> <a href='javascript:image()'>图片</a> <a href='javascript:bold()'>加粗</a></li>";
		print "<li><textarea name='article_text' rows='8' cols='80' name='l_content' id='l_content'></textarea></li>";
		print "<li><input type='hidden' name='article_id' value='' /><input type='submit' value='添加' /></li></ul></form>";
	} 

	return;
} 

//读取计划
function news($id) {
	extract($GLOBALS);

	if (is_numeric($id) && $id!="") {

	}
		else
	{

		$function_ret="";
		return $function_ret;

	} 

	$result = mysql_query($sql);
	if (!($result->eof || $result->bof)) {

		$function_ret=$result["article_text"];
	} 

	$result->close;
	return $function_ret;
} 

function NewsAddSql() {
 if (CheckAdmin()) {
		if (empty ($_POST['article_id'])) {
			$article['id']='NULL';
			$article['action']='addnew';
 	}else{
 		$article['id']=checknum($_POST['article_id']);
 		$article['action']='update';
 	}
 	
	 $article['title']=checkstr($_POST['article_title']);
	 $article['text']=checkstr($_POST['article_text']);
	 $article['date']=date('Y-m-d H:i:s');
	 $article['editor']=$_SESSION['adminname'];
	 if (empty($article['title']) || empty($article['text'])) {
	 	echo '<script language=javascript>alert("标题或内容未输入！请返回重试！")</script>';
	 	ReDirectUrl('default.php');
	 	exit;
	 }
	 if ($article['action']==='addnew') {
	 $sql="INSERT INTO article VALUES (".$article['id'].",'News','".$article['title']."','".$article['text']."','".$article['date']."','".$article['editor']."')";
	 mysql_query($sql);
	 if (mysql_affected_rows()>0) {
	 	echo '<script language=javascript>alert("'.mysql_affected_rows().' 条信息添加成功！")</script>'; 
		ReDirectUrl('default.php');
	 }
	 }else{
	 $sql="UPDATE article SET article_title='".$article['title']."',article_text='".$article['text']."',article_date='".$article['date']."',article_editor='".$article['editor']."' WHERE id=".$article['id'];
	 mysql_query($sql);
	 if (mysql_affected_rows()>0) {
	 	echo '<script language=javascript>alert("'.mysql_affected_rows().' 条信息修改成功！")</script>'; 
		ReDirectUrl('default.php');
	 }
	 }

 }
}

function NewsdelSql() {
	if (CheckAdmin() && !empty($_GET['var'])) {
		$id=checknum($_GET['var']);
		$sql="SELECT * FROM article WHERE article_class='News' and id=".$id;
		$result=mysql_query($sql);
		if (mysql_num_rows($result)===0) {
			echo '<script language=javascript>alert("您所选择的新闻不存在！")';
			ReDirectUrl('default.php');
			exit;
		}
		$sql="DELETE FROM article WHERE id=".$id;
		mysql_query($sql);
		if (mysql_affected_rows()>0) {
			echo '<script language=javascript>alert("'.mysql_affected_rows().' 条信息删除成功！")</script>';
			ReDirectUrl('default.php');
		}
	}
}


function CAbutton($id) {
	if (CheckAdmin()) {
		return " [<a href='default.php?action=edit&amp;var=".$id."'>Edit</a>] [<a href='default.php?action=del&amp;var=".$id."'>X</a>]";
	} else {
		return;
	}
} 


?>
